<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>创建分类</title>
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
		<script type="text/javascript" src="__PUBLIC__/static/js/jquery.min.js"></script>
		<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
		<script src="__PUBLIC__/static/layui/layui.js"></script>
	</head>

	<body>
		<form class="layui-form" id="layui_form" action="">
			<div class="layui-form-item" style="margin-top: 20px;">
				<label class="layui-form-label">分类名</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="name" style="width: 80%;" lay-verify="required" placeholder="请输入分类名" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">排序</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="sort" style="width: 80%;" lay-verify="required" placeholder="请输入排序" autocomplete="off" class="layui-input">
				</div>
			</div>
		  <div class="layui-form-item">
		    <div class="layui-input-block">
		      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
		      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
		    </div>
		  </div>
		</form>
	</body>
</html>
<script>
layui.use('form', function(){
  var form = layui.form;
  form.on('submit(formDemo)', function(data){
    $.ajax({
     	type:"post",
        url:"{:url('shop/types_add')}",
        data: $('#layui_form').serialize(),//表单数据
        success:function(data){
            if(data.code == 200){
            	layer.msg('添加成功', {
				  icon: 1,
				  time: 1500 //2秒关闭（如果不配置，默认是3秒）
				}, function(){
					window.parent.location.reload();
					var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
					parent.layer.close(index); 
				});
            }else{
            	layer.msg('添加失败');//保存成功提示
            }
        }
    });
    return false;
  });
});
</script>
